import requests, json

from users.models import VerifyCode
from shopping.settings import YUNPIAN_KEY,SINGLE_SEND_URL


class YunPian(object):
    """
    发送短信
    """
    # 生成短信4位数字验证码

    def send_sms(code,mobile):
        """
        :param code: 验证码
        :param mobile: 手机号
        """
        parmas = {
            "apikey": YUNPIAN_KEY,
            # 接收手机号
            "mobile": mobile,
            # 接收内容 code验证码
            "text": "【super生鲜】您的验证码是{}。如非本人操作，请忽略本短信".format(code)
        }
        #发送短信
        #response = requests.post(SINGLE_SEND_URL, data=parmas)
        #re_dict = json.loads(response.text)
        #反序列化并返回发送结果
        return 0
        # return 0
# if __name__ == "__main__":
#     yunpian = YunPian('bf5295ea71612d4377b3c3f46ad0c91b')
#     yunpian.send_sms('2018','18577957520')
